from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import QIcon
import sys


def on_delete_click():
    result = QMessageBox.question(
        w, "提示", "确认要删除吗?",
        buttons=QMessageBox.Ok | QMessageBox.Cancel,
        defaultButton=QMessageBox.Cancel
    )
    if result == QMessageBox.Ok:
        print("删除用户")
    else:
        print("取消删除")


if __name__ == '__main__':
    # 1.创建应用程序
    app = QApplication(sys.argv)

    # 2.创建窗口
    w = QWidget()

    w.resize(400, 300)

    # 修改窗口标题
    w.setWindowTitle('表单布局')

    button = QPushButton("删除用户")
    button.clicked.connect(on_delete_click)
    button.setParent(w)

    # 3.显示窗口
    w.show()

    # 4.等待窗口停止
    sys.exit(app.exec())
